package org.bonorsoft.modules.hospital.controller;


import lombok.extern.slf4j.Slf4j;
import org.bonorsoft.common.api.vo.Result;
import org.bonorsoft.common.aspect.annotation.AutoLog;
import org.bonorsoft.common.util.DateUtils;
import org.bonorsoft.modules.hospital.entity.AnalysisEntity;
import org.bonorsoft.modules.hospital.entity.TotalEntity;
import org.bonorsoft.modules.hospital.service.ITotalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @Description: 统计
* @Author: WilliamYe
* @Date:   2020-11-02
* @Version: V1.0
*/
@Slf4j
@RestController
@RequestMapping("/hospital/total")
public class TotalController {

    @Autowired
    private ITotalService totalService;


    @AutoLog(value = "统计-今日数据分析")
    @GetMapping(value = "/index")
    public Result<?> queryIndex() {
        return totalService.queryIndex();
    }

    @AutoLog(value = "统计-医保备案转诊")
    @GetMapping(value = "/record")
    public Result<?> getRecordData() {
        List<TotalEntity> recordData = totalService.getRecordData();
        return Result.ok(recordData);
    }

    @AutoLog(value = "统计-普通转诊")
    @GetMapping(value = "/common")
    public Result<?> getCommonData() {
        List<TotalEntity> commonData = totalService.getCommonData();
        return Result.ok(commonData);
    }

    @AutoLog(value = "统计-转出医院数据分析")
    @GetMapping(value = "/analysis")
    public Result<?> getAnalysisData() {
        List<AnalysisEntity> analysisData = totalService.getAnalysisData();
        return Result.ok(analysisData);
    }

    @AutoLog(value = "统计-收入院人次分析")
    @GetMapping(value = "/hospital")
    public Result<?> getHospitalAnalysis() {
        return totalService.getHospitalAnalysis();
    }

    @AutoLog(value = "统计-外请专家人次")
    @GetMapping(value = "/outside")
    public Result<?> getOutsideData() {
        List<TotalEntity> outsideData = totalService.getOutsideData();
        return Result.ok(outsideData);
    }

    @AutoLog(value = "统计-上级医院转入")
    @GetMapping(value = "/superior")
    public Result<?> getSuperiorData() {
        List<TotalEntity> outsideData = totalService.getSuperiorData(DateUtils.getYear(), 1);
        return Result.ok(outsideData);
    }

    @AutoLog(value = "统计-下级医院转入")
    @GetMapping(value = "/lower")
    public Result<?> getLowerData() {
        List<TotalEntity> outsideData = totalService.getSuperiorData(DateUtils.getYear(), 0);
        return Result.ok(outsideData);
    }
}
